package voice

import (
	"gin/tai"
	asr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/asr/v20190614"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
)

// 一句话识别 语音转文字 支持文件 或者url
func SentenceRecognition(projectId uint64, sourceType uint64, usrAudioKey string, voiceFormat string, url string, data string, dataLength int64) (*asr.SentenceRecognitionResponse, error) {
	client, _ := tai.GetAsrClient()
	request := asr.NewSentenceRecognitionRequest()

	request.EngSerViceType = common.StringPtr("8k_zh")
	request.ProjectId = common.Uint64Ptr(projectId)
	request.SourceType = common.Uint64Ptr(sourceType)

	if sourceType == 0 {
		request.Url = common.StringPtr(url)
	} else if sourceType == 1 {
		request.Data = common.StringPtr(data)
		request.DataLen = common.Int64Ptr(dataLength)
	}

	request.SubServiceType = common.Uint64Ptr(2)
	request.UsrAudioKey = common.StringPtr(usrAudioKey)
	request.VoiceFormat = common.StringPtr(voiceFormat)

	return client.SentenceRecognition(request)
}
